// 请求url配置文件
import { BGAPI_DOMAIN }from './domain';
import { getMangeTargetId } from "../biztools/wex";

// brd url prefix
const BRD_URL_PREFIX = (brandId) => {
    brandId = brandId || getMangeTargetId();
    return `${BGAPI_DOMAIN}/brd/${brandId}`;
};

// sto url prefix
const STO_URL_PREFIX = (storeId) => {
    storeId = storeId || getMangeTargetId();
    return `${BGAPI_DOMAIN}/sto/${storeId}`;
};

// 用户侧 api url
// 公共
export const USR_COMMON_URL = {
    uploadQiniuToken: `${BGAPI_DOMAIN}/usr/user/genQiniuUploadToken`,
    getCosAuthorization: `${BGAPI_DOMAIN}/usr/user/getCosAuthorization`,
    createQR: `${BGAPI_DOMAIN}/usr/user/createQR`,
    areaList: `${BGAPI_DOMAIN}/area.json`,
    config: `${BGAPI_DOMAIN}/cfg.json`,
    // 快递公司列表
    expressList: `${BGAPI_DOMAIN}/com/expressPlatforms`,
};

//  用户
export const USR_USER_URL = {
    // 用户识别(注册用户)
    userIdentify: `${BGAPI_DOMAIN}/usr/user/identify`,
    // 获取用户信息
    userInfo: `${BGAPI_DOMAIN}/usr/user/info`,
    // 根据userId获取用户信息
    specialUserInfo: userId => `${BGAPI_DOMAIN}/usr/user/${userId}/info`,
    // 更新用户信息
    updateInfo: `${BGAPI_DOMAIN}/usr/user/updateBaseInfo`,
    // 手机号验证码
    verifyCode: `${BGAPI_DOMAIN}/usr/user/genMobileVerifyCode`,
    // 绑定手机号
    bindMobile: `${BGAPI_DOMAIN}/usr/user/bindMobile`,
    // 绑定手机号(微信加密)
    bindMobileEncrypted: `${BGAPI_DOMAIN}/usr/user/bindMobileEncrypted`,
    // 特定用户粉丝
    specialUserFans: userId => `${BGAPI_DOMAIN}/usr/user/${userId}/fans`,
    // 特定用户关注(用户)列表
    specialUserFollow: userId => `${BGAPI_DOMAIN}/usr/user/${userId}/followedUsers`,
    // 特定用户关注(品牌)列表
    specialUserFollowBrand: userId => `${BGAPI_DOMAIN}/usr/user/${userId}/followedBrands`,
    // 特定用户关注(店铺)列表
    specialUserFollowStore: userId => `${BGAPI_DOMAIN}/usr/user/${userId}/followedStores`,
    // 用户粉丝
    userFans: `${BGAPI_DOMAIN}/usr/fans`,
    // 粉丝备注
    remarkFans: fansId => `${BGAPI_DOMAIN}/usr/fan/alias/${fansId}`,
    // 用户关注(用户)列表
    userFollow: `${BGAPI_DOMAIN}/usr/followedUsers`,
    // 用户关注(品牌)列表
    userFollowBrand: `${BGAPI_DOMAIN}/usr/followedBrands`,
    // 用户关注(店铺)列表
    userFollowStore: `${BGAPI_DOMAIN}/usr/followedStores`,
    // 用户资产
    userAccount: `${BGAPI_DOMAIN}/usr/user/account`,
    // 用户资金明细
    userAccountLog: `${BGAPI_DOMAIN}/usr/user/accountLogs`,
    // 用户申请提现
    userWithdraw: `${BGAPI_DOMAIN}/usr/user/accountWithdrawApplyment`,
    // 用户统计（收入&支出）
    userStatistics: `${BGAPI_DOMAIN}/usr/user/aggrUserAccountLogsToInOut`,
    // 用户敏感信息
    userPrivacy: `${BGAPI_DOMAIN}/usr/user/sensitiveInfo`,
    // 用户提现记录
    userWithdrawLog: `${BGAPI_DOMAIN}/usr/user/accountWithdrawApplyments`,
};

// 品牌
export const USR_BRAND_URL = {
    // 品牌信息
    brandInfo: brandId => `${BGAPI_DOMAIN}/usr/brand/${brandId}`,
    // 品牌配置
    brandConfig: brandId => `${BGAPI_DOMAIN}/usr/brand/${brandId}/cfg`,
};

// 店铺
export const USR_STORE_URL = {
    // 店铺信息
    storeInfo: storeId => `${BGAPI_DOMAIN}/usr/store/${storeId}`,
};

// 活动
export const USR_ACTIVITY_URL = {
    // 首页最新活动列表
    recentActivityList: `${BGAPI_DOMAIN}/usr/activities/recent`,
    // 品牌页品牌最新活动列表
    brandOwnActivityList: `${BGAPI_DOMAIN}/usr/activities/brandOwn`,
    // 店铺页品牌最新活动列表
    storeOwnActivityList: `${BGAPI_DOMAIN}/usr/activities/storeOwn`,
    // 参与的活动列表
    joinActivityList: `${BGAPI_DOMAIN}/usr/activities/involved`,
    // 代言活动列表
    endorsedActivityList: `${BGAPI_DOMAIN}/usr/activities/endorsed`,
    // 活动信息
    activityInfo: activityId =>  `${BGAPI_DOMAIN}/usr/activity/${activityId}`,
    // 获取对应的代言活动列表
    userEndorsementActivityList: spnId => `${BGAPI_DOMAIN}/usr/activities/spokesman/${spnId}`,
};

// 分销(品牌)
export const USR_DISTRIBUTE_URL = {
    // 分销设置信息、申请信息
    settingRequest: `${BGAPI_DOMAIN}/usr/endorsement/settingAndDistributeRequest`,
    // 分销申请
    request: `${BGAPI_DOMAIN}/usr/endorsement/distributeRequest`,
};

// 代言(品牌、店铺)
export const USR_ENDORSEMENT_URL = {
    // 品牌代言设置信息、申请信息
    settingBrandRequest: `${BGAPI_DOMAIN}/usr/endorsement/settingAndEndorseBrandRequest`,
    // 品牌代言申请
    brandRequest: `${BGAPI_DOMAIN}/usr/endorsement/endorseBrandRequest`,
    // 店铺代言设置信息、申请信息
    settingStoreRequest: `${BGAPI_DOMAIN}/usr/endorsement/settingAndEndorseStoreRequest`,
    // 店铺代言申请
    storeRequest: `${BGAPI_DOMAIN}/usr/endorsement/endorseStoreRequest`,
    // 代言的品牌列表
    brandList: `${BGAPI_DOMAIN}/usr/endorsement/brands`,
    // 代言的店铺列表
    storeList: `${BGAPI_DOMAIN}/usr/endorsement/stores`,
};

// 签到
export const USR_SIGNIN_URL = {
    // 品牌签到信息
    signinInfo: brandId => `${BGAPI_DOMAIN}/usr/checkIn1/fetch/${brandId}`,
    // 签到
    signinDo: `${BGAPI_DOMAIN}/usr/checkIn1/do`,
    // 中奖记录
    signinAwards: `${BGAPI_DOMAIN}/usr/checkIn1/awards`,
};

// 抽奖
export const USR_LOTTERY_URL = {
    // 品牌签到信息
    lotteryInfo: activityId => `${BGAPI_DOMAIN}/usr/lottery1/fetch/${activityId}`,
    // 签到
    lotteryDo: `${BGAPI_DOMAIN}/usr/lottery1/do`,
    // 中奖记录
    lotteryAwards: `${BGAPI_DOMAIN}/usr/lottery1/awards`,
    // 中奖人播报
    reporterAwards: `${BGAPI_DOMAIN}/usr/lottery1/awardsReporter`,
};

// 商家侧 api url
// 品牌
export const BRD_BRAND_URL = {
    preList: `${BGAPI_DOMAIN}/brd/brand-open/bilinBrands`,
    open: `${BGAPI_DOMAIN}/brd/brand-open/open`,
    list: `${BGAPI_DOMAIN}/brd/brand-open/manages`,
    brandInfo: (brandId) => `${BRD_URL_PREFIX(brandId)}/brand`,
    updateInfo: () => `${BRD_URL_PREFIX()}/brand/update`,
    getEndorsement: (brandId) => `${BRD_URL_PREFIX(brandId)}/brand/endorsement`,
    setEndorsement: () => `${BRD_URL_PREFIX()}/brand/endorsement`,
    getDistributeEndorsement: (brandId) => `${BRD_URL_PREFIX(brandId)}/brand/distributeEndorsement`,
    setDistributeEndorsement: () => `${BRD_URL_PREFIX()}/brand/distributeEndorsement`,
    getDistributeSupply: (brandId) => `${BRD_URL_PREFIX(brandId)}/brand/distributeSupplySetting`,
    setDistributeSupply: () => `${BRD_URL_PREFIX()}/brand/distributeSupplySetting`,
    getDistributeProductList: (brandId) => `${BRD_URL_PREFIX(brandId)}/brand/distributeProducts`,
    setDistributeProduct: () => `${BRD_URL_PREFIX()}/brand/distributeProduct`,
    setDistributeAllProduct: () => `${BRD_URL_PREFIX()}/brand/distributeProducts`,
    // 订单列表
    orderList: () => `${BRD_URL_PREFIX()}/orders`,
    // 订单详情
    orderDetail: (orderNumber) => `${BRD_URL_PREFIX()}/order/${orderNumber}`,
    // 订单发货
    orderDeliver: (orderNumber) => `${BRD_URL_PREFIX()}/order/${orderNumber}/deliver`,
    // 订单备货
    orderPrepare: (orderNumber) => `${BRD_URL_PREFIX()}/order/${orderNumber}/prepare`,
    // 订单提货操作
    orderPick: (orderNumber) => `${BRD_URL_PREFIX()}/order/${orderNumber}/pick`,
    // 售后单列表
    afterSaleOrderList: () => `${BRD_URL_PREFIX()}/afterSales`,
    // 售后单详情
    afterSaleOrderDetail: (orderNumber) => `${BRD_URL_PREFIX()}/afterSale/${orderNumber}`,
    // 处理售后单
    dealAfterSaleOrder: (orderNumber) => `${BRD_URL_PREFIX()}/afterSale/${orderNumber}/audit`,
    // 同意入库
    warehouseAgree: (orderNumber) => `${BRD_URL_PREFIX()}/afterSale/${orderNumber}/confirmReceive`,
    // 拒绝入库
    warehouseRefuse: (orderNumber) => `${BRD_URL_PREFIX()}/afterSale/${orderNumber}/refuseReceive`,
};

// 品牌管理员
export const BRD_ADMIN_URL = {
    list: () => `${BRD_URL_PREFIX()}/admins`,
    create: () => `${BRD_URL_PREFIX()}/admin`,
    remove: adminId => `${BRD_URL_PREFIX()}/admin/${adminId}`,
    alias: adminId => `${BRD_URL_PREFIX()}/admin/alias/${adminId}`,
};

// 品牌分销员
export const BRD_DISTRIBUTOR_URL = {
    list: (brandId) => `${BRD_URL_PREFIX(brandId)}/distributors`,
    alias: dtbId => `${BRD_URL_PREFIX()}/distributor/alias/${dtbId}`,
    requestList: () => `${BRD_URL_PREFIX()}/distributeRequests`,
    requestApprove: reqId => `${BRD_URL_PREFIX()}/distributeRequest/${reqId}/approve`,
    requestReject: reqId => `${BRD_URL_PREFIX()}/distributeRequest/${reqId}/reject`,
};

// 品牌代言人
export const BRD_SPOKESMAN_URL = {
    list: (brandId) => `${BRD_URL_PREFIX(brandId)}/spokesmans`,
    alias: spnId => `${BRD_URL_PREFIX()}/spokesman/alias/${spnId}`,
    requestList: () => `${BRD_URL_PREFIX()}/endorseRequests`,
    requestApprove: reqId => `${BRD_URL_PREFIX()}/endorseRequest/${reqId}/approve`,
    requestReject: reqId => `${BRD_URL_PREFIX()}/endorseRequest/${reqId}/reject`,
};

// 品牌粉丝
export const BRD_FANS_URL = {
    list: () => `${BRD_URL_PREFIX()}/fans`,
    alias: fansId => `${BRD_URL_PREFIX()}/fan/${fansId}/alias`,
};

// 品牌仓库
export const BRD_WAREHOUSE_URL = {
    list: (brandId) => `${BRD_URL_PREFIX(brandId)}/warehouses`,
    create: () => `${BRD_URL_PREFIX()}/warehouse`,
    update: whId => `${BRD_URL_PREFIX()}/warehouse/${whId}`,
    detail: whId => `${BRD_URL_PREFIX()}/warehouse/${whId}`,
};

// 品牌活动
export const BRD_ACTIVITY_URL = {
    create: () => `${BRD_URL_PREFIX()}/activity`,
    update: (activityId, brandId) => `${BRD_URL_PREFIX(brandId)}/activity/${activityId}`,
    detail: (activityId, brandId) => `${BRD_URL_PREFIX(brandId)}/activity/${activityId}`,
    pause: (activityId, brandId) => `${BRD_URL_PREFIX(brandId)}/activity/${activityId}/pause`,
    resume: (activityId, brandId) => `${BRD_URL_PREFIX(brandId)}/activity/${activityId}/resume`,
    publish: (activityId, brandId) => `${BRD_URL_PREFIX(brandId)}/activity/${activityId}/publish`,
    list: () => `${BRD_URL_PREFIX()}/activities`,
    statsIncome: (activityId, brandId) => `${BRD_URL_PREFIX(brandId)}/activity/${activityId}/statistics/income`,
    statsConsignment: (activityId, brandId) => `${BRD_URL_PREFIX(brandId)}/activity/${activityId}/statistics/consignment`,
    statsSpokesmanRank: (activityId, brandId) => `${BRD_URL_PREFIX(brandId)}/activity/${activityId}/statistics/spokesmanRank`,
    statsDistributorRank: (brandId) => `${BRD_URL_PREFIX(brandId)}/activitiesRankByDistributor`,
};

// 品牌微信支付申请
export const BRD_WXPAYAPPLYMENT_URL = {
    detail: () => `${BRD_URL_PREFIX()}/wxpayApplyment`,
    create: () => `${BRD_URL_PREFIX()}/wxpayApplyment`,
    update: (paymentId) => `${BRD_URL_PREFIX()}/wxpayApplyment/${paymentId}`,
    media: () => `${BRD_URL_PREFIX()}/wxpayApplyment/media`,
};

// 品牌收益、结算
export const BRD_SETTLEMENT_URL = {
    detail: () => `${BRD_URL_PREFIX()}/brand/settlementAccountInfo`,
    withdraw: () => `${BRD_URL_PREFIX()}/brand/accountWithdrawApplyment`,
    accountLogList: () => `${BRD_URL_PREFIX()}/brand/accountLogs`,
    withdrawLogList: () => `${BRD_URL_PREFIX()}/brand/accountWithdrawApplyments`,
};

// 品牌提现银行卡
export const BRD_BANKCARD_URL = {
    update: () => `${BRD_URL_PREFIX()}/brand/bankCard`,
};

// 品牌统计
export const BRD_AGGR_URL = {
    accountLogsToInOut: () => `${BRD_URL_PREFIX()}/brand/aggrBrandAccountLogsToInOut`,
};

// 品牌签到
export const BRD_SIGNIN_URL = {
    detail: () => `${BRD_URL_PREFIX()}/checkIn1/def`,
    update: () => `${BRD_URL_PREFIX()}/checkIn1/def`,
    pause: () => `${BRD_URL_PREFIX()}/checkIn1/pause`,
};

// 品牌商品
export const BRD_PRODUCT_URL = {
    list: () => `${BRD_URL_PREFIX()}/products`,
    detail: productId => `${BRD_URL_PREFIX()}/product/${productId}`,
    create: () => `${BRD_URL_PREFIX()}/product`,
    delete: productId => `${BRD_URL_PREFIX()}/product/${productId}`,
    edit: productId => `${BRD_URL_PREFIX()}/product/${productId}`,
    importList: () => `${BRD_URL_PREFIX()}/unimportedPCProducts`,
    import: () => `${BRD_URL_PREFIX()}/product/import`,
};

// 品牌商品分组
export const BRD_PRODUCT_GROUP_URL = {
    list: () => `${BRD_URL_PREFIX()}/productGroups`,
    create: () => `${BRD_URL_PREFIX()}/productGroup`,
    delete: groupId => `${BRD_URL_PREFIX()}/productGroup/${groupId}`,
    edit: groupId => `${BRD_URL_PREFIX()}/productGroup/${groupId}`,
    sort: () => `${BRD_URL_PREFIX()}/productGroup/reorder`,
};

// 订单 api url
export const ORDER_URL = {
    // 创建订单
    create: `${BGAPI_DOMAIN}/usr/order`,
    // 创建并支付
    createAndPay: `${BGAPI_DOMAIN}/usr/order/place`,
    // 订单支付
    pay: orderNumber => `${BGAPI_DOMAIN}/usr/order/${orderNumber}/repay`,
    // 订单列表
    list: `${BGAPI_DOMAIN}/usr/orders`,
    // 订单详情
    detail: orderNumber => `${BGAPI_DOMAIN}/usr/order/${orderNumber}`,
    // 取消订单
    cancel: orderNumber =>  `${BGAPI_DOMAIN}/usr/order/${orderNumber}/cancel`,
    // 确认收货
    confirmExpress: orderNumber => `${BGAPI_DOMAIN}/usr/order/${orderNumber}/receive`,
    // 确认提货
    confirmPickup: orderNumber => `${BGAPI_DOMAIN}/usr/order/${orderNumber}/pick`,
    // 售后列表
    afterSaleList: `${BGAPI_DOMAIN}/usr/afterSales`,
    // 售后详情
    afterSaleDetail: orderNumber => `${BGAPI_DOMAIN}/usr/afterSale/${orderNumber}`,
    // 提交售后单
    afterSaleApply: `${BGAPI_DOMAIN}/usr/afterSale`,
    // 取消售后订单
    afterSaleCancel: orderNumber => `${BGAPI_DOMAIN}/usr/afterSale/${orderNumber}/cancel`,
    // 更新售后单快递信息
    afterSaleExpressUpdate: orderNumber => `${BGAPI_DOMAIN}/usr/afterSale/${orderNumber}/confirmSend`,
    // 店铺订单列表
    storeOrderList: () => `${STO_URL_PREFIX()}/orders`,
    // 店铺订单详情
    storeOrderDetail: (orderNumber, storeId) => `${STO_URL_PREFIX(storeId)}/order/${orderNumber}`,
    // 店铺售后单列表
    storeAfterSaleOrderList: () => `${STO_URL_PREFIX()}/afterSales`,
    // 店铺售后单详情
    storeAfterSaleOrderDetail: (orderNumber, storeId) => `${STO_URL_PREFIX(storeId)}/afterSale/${orderNumber}`,
    // 推广订单列表
    expandOrderList: `${BGAPI_DOMAIN}/usr/bonusOrders`,
    // 推广订单详情
    expandOrderDetail: (orderNumber, spnId) => `${BGAPI_DOMAIN}/spn/${spnId}/order/${orderNumber}`,
    // 推广售后单列表
    expandAfterSaleList: `${BGAPI_DOMAIN}/usr/afterSalesAsSpokesman`,
    // 推广售后单详情
    expandAfterSaleDetail: (orderNumber, spnId) => `${BGAPI_DOMAIN}/spn/${spnId}/afterSale/${orderNumber}`,
    // 品牌过滤条件查询
    brandOrderFilter: () => `${BRD_URL_PREFIX()}/brand/searchObjects`,
    // 店铺过滤条件查询
    storeOrderFilter: () => `${STO_URL_PREFIX()}/store/searchObjects`,
    // 代言人过滤条件
    expandOrderFilter: `${BGAPI_DOMAIN}/usr/user/searchObjects`,
};

// 代言人侧 api url
// 活动
export const SPN_ACTIVITY_URL = {
    create: (spnId) => `${BGAPI_DOMAIN}/spn/${spnId}/activity`,
    statsIncome: (activityId, spnId) => `${BGAPI_DOMAIN}/spn/${spnId}/activity/${activityId}/statistics/income`,
};

// 分销商(店铺)侧 api url
// 店铺
export const STO_STORE_URL = {
    preList: `${BGAPI_DOMAIN}/sto/store-open/notOpens`,
    open: `${BGAPI_DOMAIN}/sto/store-open/openDistribute`,
    list: `${BGAPI_DOMAIN}/sto/store-open/openedStores`,
    storeInfo: (storeId) => `${STO_URL_PREFIX(storeId)}/store`,
    updateInfo: () => `${STO_URL_PREFIX()}/store/update`,
    getEndorsement: (storeId) => `${STO_URL_PREFIX(storeId)}/store/endorsement`,
    setEndorsement: () => `${STO_URL_PREFIX()}/store/endorsement`,
};

// 店铺代言人
export const STO_SPOKESMAN_URL = {
    list: (storeId) => `${STO_URL_PREFIX(storeId)}/spokesmans`,
    alias: spnId => `${STO_URL_PREFIX()}/spokesman/alias/${spnId}`,
    requestList: () => `${STO_URL_PREFIX()}/endorseRequests`,
    requestApprove: reqId => `${STO_URL_PREFIX()}/endorseRequest/${reqId}/approve`,
    requestReject: reqId => `${STO_URL_PREFIX()}/endorseRequest/${reqId}/reject`,
};

// 店铺粉丝
export const STO_FANS_URL = {
    list: () => `${STO_URL_PREFIX()}/fans`,
    alias: fansId => `${STO_URL_PREFIX()}/fan/${fansId}/alias`,
};

// 店铺活动
export const STO_ACTIVITY_URL = {
    create: () => `${STO_URL_PREFIX()}/activity`,
    update: (activityId, storeId) => `${STO_URL_PREFIX(storeId)}/activity/${activityId}`,
    detail: (activityId, storeId) => `${STO_URL_PREFIX(storeId)}/activity/${activityId}`,
    pause: (activityId, storeId) => `${STO_URL_PREFIX(storeId)}/activity/${activityId}/pause`,
    resume: (activityId, storeId) => `${STO_URL_PREFIX(storeId)}/activity/${activityId}/resume`,
    publish: (activityId, storeId) => `${STO_URL_PREFIX(storeId)}/activity/${activityId}/publish`,
    list: () => `${STO_URL_PREFIX()}/activities`,
    statsIncome: (activityId, storeId) => `${STO_URL_PREFIX(storeId)}/activity/${activityId}/statistics/income`,
    statsConsignment: (activityId, storeId) => `${STO_URL_PREFIX(storeId)}/activity/${activityId}/statistics/consignment`,
    statsSpokesmanRank: (activityId, storeId) => `${STO_URL_PREFIX(storeId)}/activity/${activityId}/statistics/spokesmanRank`,
};

// 店铺收益、结算
export const STO_SETTLEMENT_URL = {
    detail: () => `${STO_URL_PREFIX()}/store/settlementAccountInfo`,
    withdraw: () => `${STO_URL_PREFIX()}/store/accountWithdrawApplyment`,
    accountLogList: () => `${STO_URL_PREFIX()}/store/accountLogs`,
    withdrawLogList: () => `${STO_URL_PREFIX()}/store/accountWithdrawApplyments`,
};

// 店铺统计
export const STO_AGGR_URL = {
    accountLogsToInOut: () => `${STO_URL_PREFIX()}/store/aggrAccountLogsToInOut`,
};

// 店铺商品
export const STO_PRODUCT_URL = {
    list: () => `${STO_URL_PREFIX()}/products`,
    listByIds: () => `${STO_URL_PREFIX()}/productsByIds`,
};

// 店铺商品分组
export const STO_PRODUCT_GROUP_URL = {
    list: () => `${STO_URL_PREFIX()}/productGroups`,
};
